import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      home: Scaffold(
        appBar: AppBar(
          title: const Text('图片组件'),
        ),
        body: ListView(
          children: const [
            MyBody(),
            SizedBox(
              height: 20,
            ),
            CircleImg(),
            MyClipOval(),
            SizedBox(
              height: 20,
            ),
            FileImg()
          ],
        ),
      ),
    );
  }
}

class MyBody extends StatelessWidget {
  const MyBody({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        width: 400,
        height: 400,
        decoration: const BoxDecoration(color: Colors.yellow),
        child: Image.network(
          "http://fc-home.cn/zb_users/theme/tpure/style/images/boy.jpg",
          // fit: BoxFit.cover,
          repeat: ImageRepeat.repeatY,
        ),
      ),
    );
  }
}

class CircleImg extends StatelessWidget {
  const CircleImg({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 150,
      height: 150,
      decoration: BoxDecoration(
          color: Colors.green,
          borderRadius: BorderRadius.circular(75),
          image: const DecorationImage(
            image: NetworkImage(
                "http://fc-home.cn/zb_users/theme/tpure/style/images/boy.jpg"),
            fit: BoxFit.cover,
          )),
    );
  }
}

class MyClipOval extends StatelessWidget {
  const MyClipOval({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: ClipOval(
        child: Image.network(
          "http://fc-home.cn/zb_users/theme/tpure/style/images/boy.jpg",
          fit: BoxFit.cover,
          repeat: ImageRepeat.repeatY,
          width: 150,
          height: 150,
        ),
      ),
    );
  }
}

class FileImg extends StatelessWidget {
  const FileImg({super.key});

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 150,
      width: 400,
      child: Image.asset("images/VCG211223709635.png"),
    );
  }
}
